Skip to content

test(fonts): font availability + curation behavior matrix (SD-3441)#3733

Closed
caio-pizzol wants to merge 9 commits into
mainfrom
caio-pizzol/font-availability-tests
Closed

test(fonts): font availability + curation behavior matrix (SD-3441)#3733
caio-pizzol wants to merge 9 commits into
mainfrom
caio-pizzol/font-availability-tests

Conversation

@caio-pizzol

Copy link
Copy Markdown
Contributor

Behavior coverage for the config-gated bundled fonts from SD-3441, so the npm and CDN paths are verified end to end instead of by inspection.

It drives the bundled-font modes through the existing behavior harness with a new fonts config option, plus a /fonts/ middleware that serves the built pack so real face loads are assertable. The default mode keeps the rich pack, so existing toolbar specs are unaffected.

Covered so far (npm, green locally on chromium):

  • no-pack: the toolbar is the baseline only, and a no-pack document keeps its font names without fetching any substitute (the 1.40 regression guard).
  • curation: include drops the built-in baseline, exclude removes only the named family.
  • pack: applying Calibri loads its substitute (200) and stores the logical name, never Carlito.
  • malformed raw fonts.bundled warns once and falls back to the full pack, never crashing init.

Still to come, and why this is a draft:

  • a CDN static harness (default, missing fonts, raw curation)
  • a real @superdoc-dev/fonts import smoke test (the package's resolveAssetUrl flow, distinct from the assetBaseUrl harness)
  • custom-font render vs selectable split, the 404-base warning, programmatic apply, and two-instance isolation

Review: the harness change must stay backward-compatible (no fonts param = rich pack); confirmed against the existing font dropdown spec.
Verified: playwright test tests/fonts --project=chromium green; existing font-dropdown-document-options.spec.ts still green.

Drive the bundled-font modes through the existing behavior harness via a
`fonts` config option (no-pack / curation / malformed raw / bad base),
and serve the built dist/fonts at /fonts/ so face loads are assertable.

Covers: no-pack baseline (exact + rich-absent), include drops the built-in
baseline, exclude removes only the named family, applying Calibri loads its
substitute (200) and stores the logical name not Carlito, and malformed raw
fonts.bundled warns once without crashing. Default mode keeps the rich pack,
so existing toolbar specs are unaffected.
…on (SD-3441)

Load a Calibri document with no pack configured and assert it fetches no
bundled .woff2, keeps the logical Calibri name on the run, and still lists
Calibri in the toolbar as a document font. Guards the 1.40 regression:
preserving a document's font name must not activate a substitute the app
never configured.
@linear-code

linear-code Bot commented Jun 13, 2026

Copy link
Copy Markdown

SD-3441

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Add a `package` harness mode that imports superdocFonts from
@superdoc-dev/fonts (aliased to source in the harness, so no dep churn) and
asserts applying Calibri loads Carlito 200 from the package's bundler-emitted
asset (new URL(import.meta.url)), with no assetBaseUrl. Proves the
import-and-go DX the assetBaseUrl harness does not cover.
…nts/ (SD-3441)

The /fonts/ middleware made bundled substitutes load for every spec (the
harness default assetBaseUrl is /fonts/), so specs reading a rendered font -
e.g. list-marker-font-inheritance - saw Liberation Serif instead of Times New
Roman. Serve the assets at a distinct /bundled-fonts/ base used only by the
pack font mode, leaving the default /fonts/ unserved (its prior state) so
substitutes are advertised but not loaded.
@caio-pizzol caio-pizzol marked this pull request as ready for review June 14, 2026 00:46
@caio-pizzol caio-pizzol requested a review from a team as a code owner June 14, 2026 00:46

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6a19d5e5d1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread tests/behavior/harness/vite.config.ts
The package-import spec resolves faces to packages/fonts/assets via the
source alias. That dir is gitignored and generated by the fonts package's
prepare/build, which behavior CI skips (--ignore-scripts; root build only
builds superdoc). The spec passes in CI today via an ambient workspace
mechanism, but relying on it is fragile - so sync the assets explicitly in
the Playwright webServer command. Verified cold: cleared assets + Vite cache
-> sync writes 65 faces -> Carlito loads 200.
…st the count (SD-3441)

The shared-registry first-config-wins contract (#14) is already covered here;
tighten the assertion so it checks the warning explains WHY the later config
was dropped, not merely that console.warn fired once.
…-3441)

bad-url: a configured-but-broken assetBaseUrl still advertises the rich set
(presence-gated) and requests faces from exactly that base, staying graceful
(run keeps the logical name). Note: SuperDoc does not emit its own
load-failure warning - the browser reports the decode failure - and the Vite
harness returns an SPA fallback rather than a 404, so this asserts base-honoring
+ graceful fallback, not a 404.

programmatic apply (no pack): applying a bundled font via the editor command
keeps the logical name and fetches no substitute - the resolver gate, UI-aside.
Add 'custom' / 'custom-toolbar' harness modes that register a licensed font
('Brand Sans', sourced from a served woff2) via fonts.families, optionally
listing it in modules.toolbar.fonts. Two specs lock the contract: registration
alone renders the font when applied but does NOT add a toolbar option;
listing it in modules.toolbar.fonts makes it selectable. Also fix the now-stale
npm-font-availability header.
Trim the wordiest comment to the why (base-honored; no 404/SuperDoc warning -
browser reports the decode failure, Vite serves an SPA fallback). Other
comments encode real contracts and stay.
@superdoc-bot superdoc-bot Bot closed this in a3af779 Jun 14, 2026
@superdoc-bot

superdoc-bot Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

This pull request landed on main as a3af779.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants